﻿using System;
using System.Collections.Generic;
using System.Text;
using NetworkLib.Utilities;

namespace PokemonBattle.BattleNetwork
{
    public enum TargetIndex : int
    {
        DefaultTarget = -1865455426,
        Opponent1 = -536926594,
        Opponent2 = -536926597,
        TeamFriend = -1044722981,
        Self = -710105077,
        Random = -353152975,
        WrongInput = -1
    }
    public static class TargetIndexHelper
    {
        public static TargetIndex ReadFromByteArray(ByteArray byteArray)
        {
            int val = byteArray.ReadInt();
            return Parse(val);
        }

        public static TargetIndex Parse(int val)
        {
            foreach (int value in Enum.GetValues(typeof(TargetIndex)))
            {
                if (value == val) return (TargetIndex)value;
            }
            return TargetIndex.WrongInput;
        }

        public static void WriteToByteArray(ByteArray byteArray, TargetIndex value)
        {
            byteArray.WriteInt((int)value);
        }
    }
}
